<template>
	<div>
		<headerNave :nva-datas="navDatas" v-on:backNav="backNav"></headerNave>
		<components :is="currentView" v-on:changeView="changeView" v-on:backPrev="backPrev" :template-obj="templateObj"></components>
	</div>
</template>
<script>
	import $ from 'jquery'
	import headerNave from '../../../../components/headerNave'
	import { GloabFun, Animation, HttpServer } from '../../../../assets/js/common.js'
	//统计列表
	const List = resolve => require(['./List.vue'], resolve)
	//统计图
	const Detail = resolve => require(['./Detail.vue'], resolve)
	//EBox统计图
	const EBoxDetail = resolve => require(['./EBoxDetail.vue'], resolve)
	//pdu统计图
	const pduDetail = resolve => require(['./PduDetail.vue'], resolve)
	export default {
		components: {
			List,
			Detail,
			pduDetail,
			EBoxDetail,
			headerNave
		},
		data() {
			return {
				currentView: "List",
				templateObj: {
					DistrictId: this.subArgs.DistrictId,
					CurrentView: this.subArgs.CurrentView
				},
				navDatas: [{
					name: '数据统计',
					view: ""
				}, {
					name: this.subArgs.CurrentView,
					view: "List"
				}]
			};
		},
		props: {
			subArgs: {
				type: Object,
				default: {}
			}
		},
		methods: {
			changeView(view, obj) {
				GloabFun.clearRecordPreview.call(this);
				obj.DistrictId = this.subArgs.DistrictId;
				obj.CurrentView = this.subArgs.CurrentView;
				Animation.animation($("#mainContent"), function() {
					if(obj) {
						this.navDatas = [{
							name: '数据统计',
							view: ""
						}, {
							name: this.subArgs.CurrentView,
							view: "List"
						}];
						this.templateObj = obj;
						if(view === "Detail") {
							this.navDatas.push({
								name: "耗电详情->" + obj.name,
								view: "Detail"
							});
						} else if(view === "pduDetail") {
							this.navDatas.push({
								name: "耗电详情",
								view: "Detail"
							});
							this.navDatas.push({
								name: "电源管理器耗电详情->" + obj.pduname,
								view: "pduDetail"
							});
						} else if(view === "EBoxDetail"){
							this.navDatas.push({
								name: "智慧空开用电详情统计->" + obj.name,
								view: "Detail"
							});
						}
					}
					this.currentView = view;
				}.bind(this));
			},
			backPrev() {
				this.$emit('backPrev');
			},
			backNav(item) {
				if(item.view === "List") {
					this.changeView("List", this.templateObj);
				} else if(item.view === "Detail") {
					this.changeView("Detail", this.templateObj);
				}
			}
		}
	}
</script>